// 怀旧滤镜
const reminiscence = function (imgData) {
    for (var i = 0; i < imgData.height * imgData.width; i++) {
        var r = imgData.data[i*4],
            g = imgData.data[i * 4+1],
            b = imgData.data[i * 4+2];

        var newR = (0.393 * r + 0.769 * g + 0.189 * b);
        var newG = (0.349 * r + 0.686 * g + 0.168 * b);
        var newB = (0.272 * r + 0.534 * g + 0.131 * b);
        var rgbArr = [newR, newG, newB].map((e) => {
            return e < 0 ? 0 : e > 255 ? 255 : e;
        });
        [imgData.data[i*4], imgData.data[i * 4+1], imgData.data[i * 4+2]] = rgbArr;
    }

    return imgData;
}

export default reminiscence;